package com.ostrich.library_base

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding

abstract class BaseFragment<VDB: ViewDataBinding>  : Fragment() {

    var binding:VDB? = null
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?,
    ): View? {
        binding = DataBindingUtil.inflate(inflater,bindLayout(),container,false)
        initView()
        initData()
        initListener()
        return binding?.root
    }


    override fun onDestroyView() {
        super.onDestroyView()
        if(binding != null){
            binding = null
        }
    }

    abstract fun initView()
    abstract fun initData()
    abstract fun initListener()
    abstract fun bindLayout():Int

}